package com.fengping.album.camerax

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout

/**
 * @author qianjujun
 * @email qianjujun@163.com
 * @createTime 2021/1/6 18:45
 * @describe
 */
class AspectRatio43View : ConstraintLayout {
    constructor(context: Context) : super(context) {}
    constructor(
        context: Context,
        attrs: AttributeSet?
    ) : super(context, attrs) {
    }

    constructor(
        context: Context,
        attrs: AttributeSet?,
        defStyleAttr: Int
    ) : super(context, attrs, defStyleAttr) {

    }


    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        val width = MeasureSpec.getSize(widthMeasureSpec)
        val height : Float = width * 4 / 3f
        super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(height.toInt(), MeasureSpec.EXACTLY))
    }
}